<template>
  <div class="keyClasp">
    <div>
      <ele-page
        ref="eleTable"
        v-loading="loading"
        :formConfig="searchConfig"
        :operateList="operateList"
        :column="column"
        :getList="getList"
        uniqueId="mesProcessTable"
        @handleOperateEvent="handleOperateEvent"
      >
      </ele-page>
    </div>
    <accredit-drawer
      ref="accreditDrawer"
      @refresh="refresh"
    />
  </div>
</template>

<script>
import { operateList, searchConfig, rowConfig } from './config'
import { getList, getRoleList, setRole } from '@/api/cabinet/accredit'
import url from '@/axios/url'
import accreditDrawer from './accreditDrawer.vue'
const { minioUrl } = url()
export default {
  name: 'mesProcess',
  mixins: [searchConfig, operateList],
  components: {
    accreditDrawer
  },
  data() {
    return {
      processCodeList: [],
      loading: false,
      // operateList,
      getList,

      // 列表页字段的绑定配置
      column: [
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60,
          fixed: 'left'
        },
        {
          prop: 'cabinetSite',
          label: $i18n.t('cabinet.cabinetArea'),
          minWidth: 200,
          showOverflowTooltip: true
        },
        {
          prop: 'roleCodeName',
          label: $i18n.t('cabinet.accreditRole'),
          minWidth: 300,
          showOverflowTooltip: true
        },
        {
          prop: 'operate',
          label: $i18n.t('common.operation'),
          width: 80,
          fixed: 'right',
          render: (h, scope) => {
            return <ele-row-operation scope={scope} rowConfig={rowConfig} onRowOperate={this.rowOperate} />
          }
        }
      ]
    }
  },
  computed: {},
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (row.iddss === 1) {
        return 'warning-row'
      } else {
        return 'success-row'
      }
    },
    // 表格顶部按钮操作事件
    handleOperateEvent(data) {
      this.title = data.name
      const fnc = {
        // accreditBatch: () => {
        //   if (data.rows.length > 0) {
        //     this.$refs.accreditDrawer.actionType = 2
        //     this.$refs.accreditDrawer.drawer = true
        //   } else {
        //     this.$message.warning($i18n.t('common.single'))
        //   }
        // }
      }
      fnc[data.handleName]()
    },
    // 表格行操作事件
    rowOperate({ handleName, name, row }) {
      this.title = name
      const fnc = {
        accredit: () => {
          this.$refs.accreditDrawer.drawer = true
          this.$refs.accreditDrawer.actionType = 1
          this.$refs.accreditDrawer.getRoleData(row.cabinetSiteId, row.cabinetSite)
          this.$refs.accreditDrawer.getCabinetData(row.cabinetSiteId)
        }
      }
      fnc[handleName]()
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset)
    }
  }
}
</script>
<style scoped lang="scss">
.mesProcess {
  /deep/.el-transfer-panel {
    width: 40% !important;
  }
  .warning-row {
    background: oldlace;
  }
}
</style>
